package com.example.springblog.mapper;

import com.example.springblog.model.BlogInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper {
    //1,查询博客列表
    @Select("select * from blog where delete_flag=0 order by create_time desc")//做一个降序 升序ASC
    List<BlogInfo> selectBlog();
    //2.根据博客ID,查询博客信息
    @Select("select * from blog where id = #{id} and delete_flag = 0")
    BlogInfo selectBlogByID(Integer id);

    //3,根据博客ID,修改博客信息
    int updateBlogByID(BlogInfo blogInfo);

    //4,插入博客。
    @Insert("insert into blog (title,content,user_id) values(#{title},#{content},#{userId})")
    void addBlog(BlogInfo blogInfo);
}
